<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@page import="itsm.isperp.framework.core.context.ContextHolder"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<%
  String path = request.getContextPath();
			String basePath = ContextHolder.getWebServerName(request);
%>


	<div class="weui-cells" style="margin-top:10px;background-color:#f8f8f8;position:absolute;bottom:0;top:0;left:0;right:0" id="listContainer">

		<c:forEach var="incident" items="${incidents }">

           <c:choose>
              <c:when test="${type eq '2' }">
                 <a class="weui-cell weui-cell_access"  style="margin-top:3px;"
				href="<%=basePath%>api/wechat/incident/userSatisfaction?id=${incident.id }&openid=${openid}">
				<div class="weui-cell__bd">
					<h4 class="weui-media-box__title" style='font-size:17px;'>${incident.title }</h4>
					<p class="weui-media-box__desc">${incident.status }</p>
				</div>
				<div class="weui-cell__ft" style="font-size:14px;">
					<fmt:formatDate value="${incident.createDate }"
						pattern="yyyy-MM-dd HH:mm" />
				</div> </a>
              </c:when>
              <c:otherwise>
                 <a class="weui-cell weui-cell_access" style="margin-top:3px;"
				href="<%=basePath%>api/wechat/incident/incidentInfo?id=${incident.id }">
				<div class="weui-cell__bd">
					<h4 class="weui-media-box__title" style='font-size:17px;'>${incident.title }</h4>
					<p class="weui-media-box__desc">${incident.status }</p>
				</div>
				<div class="weui-cell__ft" style="font-size:14px;">
					<fmt:formatDate value="${incident.createDate }"
						pattern="yyyy-MM-dd HH:mm" />
				</div> </a>
              </c:otherwise>
           </c:choose>
			
				
				
		</c:forEach>
	</div>


<div class="weui-tabbar" style="bottom:0px;position:fixed">
	<a href="myIncident?type=1&openid=${openid }" class="weui-tabbar__item" id="a_1"> <span
		style="display: inline-block;position: relative;"> <img
			src="../../../img/wechat/ml1.jpg" alt=""
			class="weui-tabbar__icon">
			<p class="weui-tabbar__label">处理中</p>
	</a> <a href="myIncident?type=2&openid=${openid }" id="a_2"
		class="weui-tabbar__item "> <img
		src="../../../img/wechat/ml2.jpg" alt=""
		class="weui-tabbar__icon"> <span class="weui-badge" id="weui-badge"
		style="position: absolute;top: 2px;display:none">0</span>
		<p class="weui-tabbar__label" style="margin-top:5px;margin-bottom:3px;">待评价</p> </a> <a
		href="myIncident?type=3&openid=${openid }" id="a_3"
		class="weui-tabbar__item"> <img
		src="../../../img/wechat/ml3.jpg" alt=""
		class="weui-tabbar__icon"> 
		<p class="weui-tabbar__label">已评价</p> </a>
</div>
<script type="text/javascript">

   $(function(){
      var type='${type}' || 1;
       $("#a_"+type).attr("class","weui-tabbar__item weui-bar__item_on");
     // getList(type);
      $.ajax({
        url:'getToCloseIcdCount?openid=${openid}',
        success:function(data)
        {
           if(data>0)
              $("#weui-badge").text(data).show();
           else
              $("#weui-badge").text("0").hide();
        }
      });
   });
   
	function getList(type) {
	     $(".weui-bar__item_on").attr("class","weui-tabbar__item");
	    $("#a_"+type).attr("class","weui-tabbar__item weui-bar__item_on");
	
		var cusUserId = '${cusUserId}';
		var openid = '${openid}';
		$("#listContainer").html("");
		$.ajax({url : 'getMyIncident?openid=' + openid + '&type=' + type,
					success : function(data) {
						var listStr = "";
						var dataLength=data.length;	
						 $("#listContainer").html("");				
						if (dataLength > 0) {
						   
							for ( var i = 0; i < dataLength; i++) {
								var title = data[i].title;
								var id = data[i].id;
								var status = data[i].status;
								var createDate = data[i].createDate;
								var href="<%=basePath%>api/wechat/incident/incidentInfo?id="+id+"&type="+type;
								if(type!="1")
								    href="<%=basePath%>api/wechat/incident/userSatisfaction?id="+id+"&openid="+openid;
								listStr += "<a class='weui-cell weui-cell_access' href='"+href+"'>"
										+ "<div class=\"weui-cell__bd\"><h4 class=\"weui-media-box__title\" style='font-size:17px;'>"
										+ title
										+ "</h4>"
										+ "<p class=\"weui-media-box__desc\">"
										+ status
										+ "</p></div>"
										+ "<div class=\"weui-cell__ft\" style=\"font-size:14px;\">"
										+ createDate + "</div> </a>";
							}
							$("#listContainer").append(listStr);
						}else
						{
						   $("#listContainer").append("<a class='weui-cell weui-cell_access' style='padding:18px;' href=''>无记录</a>");
						}

					}
				});

	}
</script>
